from sqlalchemy import Column, Integer, String, Boolean, Float, ForeignKey, DateTime, BigInteger
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class User(Base):
    __tablename__ = 'users'

    id = Column(BigInteger, primary_key=True)
    first_name = Column(String)
    last_name = Column(String)
    username = Column(String)
    is_admin = Column(Boolean, default=False)
    # token = Column(String)
    bookings = relationship("Booking", back_populates="user")


class Tour(Base):
    __tablename__ = 'tours'

    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String)
    description = Column(String)
    price = Column(Float)
    photo = Column(String)
    duration = Column(String)
    bookings = relationship("Booking", back_populates="tour")


class Booking(Base):
    __tablename__ = 'bookings'

    id = Column(Integer, primary_key=True, autoincrement=True)
    user_id = Column(Integer, ForeignKey('users.id'))
    tour_id = Column(Integer, ForeignKey('tours.id'))
    date = Column(DateTime)

    user = relationship("User", back_populates="bookings")
    tour = relationship("Tour", back_populates="bookings")
